Navigation

Data Abstraction

make implementation irrelevant; manipulate the concept, not the data

Data/Object Anti-Symmetry

modeling

paradigms

The Law of Demeter

Any method f of class C should only call the methods of…

…and should not call methods on objects returned from the allowed.

“Talk to friends, not to strangers.”

Train Wrecks

Long chains digging deeply into nested objects requires a function to know too much about the rest of the application, but data structures are fine.

Hybrids

Avoid: a mixed object and data structure; hard to add to, hard to change.

Hiding Structure

Objects do something; don’t ask for internals. Instead of asking for internals, move implementation into the object.

Data Transfer Objects

data structures which collect raw data (e.g. database row, socket data) into a known, compiler-parsable structure.

“Beans” are data transfer objects which have getters/setters for every property and no other methods

Active Record

data structures with database methods only. Put business rules in separate classes.

Conclusion